<template>
  <div class="app-container">
    <el-form
      ref="onlieForm"
      :model="onlieForm"
      :rules="rules"
      label-width="80px">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item
            label="号码"
            prop="phone">
            <el-input
              placeholder="请输入号码"
              v-model="onlieForm.phone"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="加密方式"
            prop="encrypt_mask">
            <el-select v-model="onlieForm.encrypt_mask" placeholder="请选择" style="width:100%;">
              <el-option :label="encrypt.label" :value="encrypt.value" :key="encrypt_index" v-for="(encrypt, encrypt_index) in encryptOptions"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { onlineStateSend } from '@/api/product';
export default {
  name: 'onlineTransfer',
  props: {
    productNo: {
      type: [String, Number],
      default: '',
    },
    is_encrypt:{
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      onlieForm: {
        phone: '',
        encrypt_mask:""
      },
      encryptOptions:[
        {
          value:"MD5",
          label:'MD5'
        },
        {
          value:"SHA256",
          label:'SHA256'
        },
      ],
      rules: {
        phone: { required: true, trigger: 'blur', message: '请填写号码' },
        encrypt_mask: { required: true, trigger: 'blur', message: '请选择加密方式' },
      },
    };
  },
  methods: {
    handleSubmit() {
      this.$refs.onlieForm.validate(valid => {
        if (valid) {
          let params = { ...this.onlieForm };
          params['product_no'] = this.productNo;
          this.$emit('update:loadingButton', ['submit']);
          onlineStateSend(params).then(res => {
            this.$message.success(res.message);
            this.$emit('update:visible', false);
          }).finally(()=>{
            this.$emit('update:loadingButton', []);
          });
        }
      });
    },
  },
};
</script>
